function [ FA ] = random_alg( dataset, k, m )
%random_alg Random algorith described in section 4, alg 1
%   Picks random placement and schedule. There are k time slots.
%   Pick m sensors from the dataset.
    
    % This matrix stores all possible times, and what sensors are in them
    % Zeros represent empty slots. Since this is matlab, the matrix is big
    ats = zeros(k, m);

    % First, randomly pick m sensors.
    notpicked = 1;
    for i=2:size(dataset,2)
        notpicked = union(notpicked, i);
    end
    picked = [];
    for i=1:m
        newval = notpicked(randi(size(notpicked)));
        picked = union(picked, newval);
        notpicked = setdiff(notpicked, newval);
    end
    
    % Assign a random time slot to each sensor
    sensors = [picked; zeros(1, m)];
    for i=1:size(sensors,2)
        time_slot = randi(k);
        sensors(2,i) = time_slot;
        ats(time_slot,i) = dataset(1,sensors(1,i));
    end
    

    % for each time slot, compute F(At)
    for i=1:k
        % grow the set A, reduce setBar
        set = [];
        setBar = dataset;
        n=1;
        while n<=size(setBar,2)
            % delete the node data from setBar if it's node ID shows up in the current partition
            if ismember(setBar(1,n),ats(i,:))
                set = [set setBar(:,n)];
                setBar(:,n) = [];
            else
                n = n + 1;
            end
        end
        
        % compute the quality and store it
        FA(i) = sensingQuality(set(2:end,:),setBar(2:end,:));        
    end

end
